package com.banksoft.cps.util;

public class PageUtils
{
    public static int getOffset(int pageSize, int page)
    {
        return (page - 1) * pageSize;
    }

    public static int getPage(int count, int pageSize)
    {

        int page = (int) Math.ceil(count / pageSize);
        if((count % pageSize)>0){
            page = page+1;
        }
        return page >= 1 ? page : 1;
    }

    public static long getPage(long count, long pageSize)
    {
        if(pageSize == 0){
            return 0;
        }
        int page = (int) Math.ceil(count / pageSize);
        if((count % pageSize)>0){
            page = page+1;
        }
        return page >= 1 ? page : 1;
    }


}

